#ifndef __DEV_UART_HEAD__
#define __DEV_UART_HEAD__

#include <iostream>
#include <unistd.h>
#include <string.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>

using namespace std;

class Dev_Uart
{
public:
    Dev_Uart(const string &devicename,const uint32_t baudRate = 115200);

    ~Dev_Uart();

    uint16_t readUartData(char* buf,const uint16_t size);

    uint16_t writeUartData(char* buf,const uint16_t size);

    // 接收固定大小的数据
    bool receiveFixedSizeData(char* buf,uint16_t size);

private:
    bool uartInit(uint32_t baudRate) const;
private:
    int fd; // 串口的文件描述符
    uint32_t baudRate;
};

#endif